import {
  articlePublishApi,
  dynamicPublishApi,
  topicListApi,
  uploadApi,
  videoPublishFunApi,
} from '../api/publishApi';

/**
 * @param keyword    关键字
 */
export const topicListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    topicListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/** 上传单张图片 */
export const uploadFileFun = (filePath: string, name: string, extra: any) => {
  return uploadApi(filePath, name, extra);
};

// 发布动态
export const dynamicPublishFun = (data: any) => {
  return new Promise((reslve: any, reject: any) => {
    dynamicPublishApi(data)
      .then((res: any) => {
        reslve(res);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

// 发布视频
export const videoPublishFun = (data: any) => {
  return new Promise((reslve: any, reject: any) => {
    videoPublishFunApi(data)
      .then((res: any) => {
        reslve(res);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

// 发布文章
export const articlePublishFun = (data: any) => {
  return new Promise((reslve: any, reject: any) => {
    articlePublishApi(data)
      .then((res: any) => {
        reslve(res);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};
